package cn.lzit.session;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

//@WebServlet(name="OrderServlet",urlPatterns = "/OrderServlet")
public class OrderServlet extends HttpServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=utf-8");

        request.setCharacterEncoding("UTF-8");

        String foodName[] = request.getParameterValues("foodName");

        if (foodName != null) {
            for (int k = 0; k < foodName.length; k++) { // 遍历所有的食品名称
                request.setAttribute("foodName" + k, foodName[k]); // 将每个食品名称设置为request的一个属性
            }
        }
        String url="<A href='http://localhost:8080/sy04_war_exploded/CartServlet'>欢迎去购物车页面！></A>";
        response.getWriter().print("<p>点击超链接，链接到购物车页面，去查看购物车中的商品。<br/>"+url);
    }
    protected void doPost(HttpServletRequest request,HttpServletResponse response)throws  ServletException,IOException{
        doGet(request,response);
    }
}